package jin.si.com.xc;

import org.apache.poi.ss.formula.functions.T;

/**
 * @description:
 * @ClassName Lianxi2
 * @Author MT
 * @Date 2021/7/3 16:35
 **/
public class Lianxi2 implements Runnable{

    public Lianxi2(){};
    public Lianxi2(String name){

    }

    private static int num=100;
    @Override
    public void run() {

        while(true){
            if(num%2==0){
                synchronized(this){
                    if(num>0){
                        System.out.println(Thread.currentThread().getName()+"偶数："+num);
                        num--;
                    }
                }
            }else{
                method2();
            }
        }

    }

    public void method1(){
        if(num>0){
            System.out.println(Thread.currentThread().getName()+"奇数："+num);
            num--;
        }
    }

    public static void method2(){
        if(num>0){
            System.out.println(Thread.currentThread().getName()+"奇数："+num);
            num--;
        }
    }



}
